﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight;
using System.Windows.Input;
using GalaSoft.MvvmLight.Command;

namespace TriviaViewModel
{
    public class DifficultyAndTopicViewModel : ViewModelBase
    {
        /// <summary>
        /// difficulty added
        /// </summary>
        private string _difficultyAdded;
        public string DifficultyAdded
        {
            get { return _difficultyAdded; }
            set
            {
                if (_difficultyAdded != value)
                {
                    _difficultyAdded = value;
                    RaisePropertyChanged("DifficultyAdded");
                }
            }

        }

        /// <summary>
        /// topic added
        /// </summary>
        private string _topicAdded;
        public string TopicAdded
        {
            get { return _topicAdded; }
            set
            {
                if (_topicAdded != value)
                {
                    _topicAdded = value;
                    RaisePropertyChanged("TopicAdded");
                }
            }
        }

        public ICommand AddDiddicultyCommand { get; set; }
        public ICommand AddTopicCommand { get; set; }

        public DifficultyAndTopicViewModel()
        {
            AddDiddicultyCommand = new RelayCommand(() => AddDifficultyCommandExecute());
            AddTopicCommand = new RelayCommand(() => AddTopicCommandExecute());
        }


        private void AddDifficultyCommandExecute()
        {
            using (var proxy = new ServiceReference1.GameServiceClient())
            {
                proxy.AddDificulty(DifficultyAdded);
            }
        }

        private void AddTopicCommandExecute()
        {
            using (var proxy = new ServiceReference1.GameServiceClient())
            {
                proxy.AddTopic(TopicAdded);
            }
        }
    }
}
